import {
  Dispatch,
  Fragment,
  RefObject,
  SetStateAction,
  useCallback,
  useImperativeHandle,
  useRef,
} from "react";
import aaa from "./inpAndBtn";

export default ({
  getOneHomeNum,
  setNumSta,
  inpRef,
}: {
  getOneHomeNum: number[];
  setNumSta: Dispatch<SetStateAction<number[]>>;
  inpRef: RefObject<{
    focusAddComment: () => void;
  }>;
}) => {
  const func2 = useCallback(
    (orderDetails: number[]) => {
      return [...orderDetails, +Math.random().toFixed(2)];
    },
    [getOneHomeNum]
  );

  const commentsRef = useRef(null);
  commentsRef.current;
  return (
    <Fragment>
      <div>
        <button
          onClick={() => {
            inpRef?.current?.focusAddComment()
          }}
        >
          触发输入框焦点
        </button>
      </div>
      <div>
        <button
          onClick={() => {
            setNumSta(func2(getOneHomeNum));
          }}
        >
          增加随机数
        </button>
      </div>
    </Fragment>
  );
};
